package com.springmvc.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@SessionAttributes(value = {"x","y"})
public class SessionScopeTestController {
    @RequestMapping("/testSessionScope1")
    public String testSessionScope1(HttpSession session) {
        session.setAttribute("sessionScope", "在spring当中使用原生servlet API完成session域共享");
        return "Ok";
    }
    @RequestMapping("/testSessionScope2")
    public String testSessionScope2(Model  model) {
        model.addAttribute("x", "在spring当中使用Model完成session域共享x");
        model.addAttribute("y", "在spring当中使用Model完成session域共享y");
        return "Ok";

    }
}
